package com.bringway.p2p.controller;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.bringway.framework.controller.JsonController;
import com.bringway.p2p.domain.News;
import com.bringway.p2p.service.NewsService;

import net.sf.json.JSONObject;

@Controller
@RequestMapping("/news")
public class NewsController extends JsonController{
	@Autowired
	private NewsService newsService;
	@RequestMapping("/getNews")
	public ModelAndView getNews(HttpServletRequest request,HttpServletResponse response) throws Exception{
		News n = newsService.getNews();
		List<News> list = new ArrayList<News>();
		list.add(n);
		JSONObject result = new JSONObject();
		result.put("data", list);
		serialize(request, response, result);
		return null;
	}
}